﻿/*
版权所有：版权所有(C) 2011，刘建新
文件编号：M01_Maintain.cs
文件名称：Maintain.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2011-02-15
作　　者：
内容摘要：表[Maintain]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.Bus
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：Maintain
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class Maintain : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is Maintain)
				{
					if (obj == this)
						return true;
					Maintain castObj = (Maintain)obj; 
					
					if (!this.m_Seqno.Equals(castObj.Seqno))
						return false;
						
					if (!this.m_用户姓名.Equals(castObj.用户姓名))
						return false;
						
					if (!this.m_联系电话.Equals(castObj.联系电话))
						return false;
						
					if (!this.m_联系地址.Equals(castObj.联系地址))
						return false;
						
					if (!this.m_产品型号.Equals(castObj.产品型号))
						return false;
						
					if (!this.m_订单号.Equals(castObj.订单号))
						return false;
						
					if (!this.m_Email.Equals(castObj.Email))
						return false;
						
					if (!this.m_故障说明.Equals(castObj.故障说明))
						return false;
						
					if (!this.m_Isdo.Equals(castObj.Isdo))
						return false;
						
					if (!this.m_Buydate.Equals(castObj.Buydate))
						return false;
						
					if (!this.m_Createdate.Equals(castObj.Createdate))
						return false;
						
					if (!this.m_Createby.Equals(castObj.Createby))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_Seqno != null)
					{
						hash = hash ^ m_Seqno.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_用户姓名 != null)
					{
						hash = hash ^ m_用户姓名.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_联系电话 != null)
					{
						hash = hash ^ m_联系电话.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_联系地址 != null)
					{
						hash = hash ^ m_联系地址.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_产品型号 != null)
					{
						hash = hash ^ m_产品型号.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_订单号 != null)
					{
						hash = hash ^ m_订单号.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Email != null)
					{
						hash = hash ^ m_Email.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_故障说明 != null)
					{
						hash = hash ^ m_故障说明.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Isdo != null)
					{
						hash = hash ^ m_Isdo.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Buydate != null)
					{
						hash = hash ^ m_Buydate.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Createdate != null)
					{
						hash = hash ^ m_Createdate.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Createby != null)
					{
						hash = hash ^ m_Createby.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public Maintain()
			{
				MarkNew();
			}						
			
			public Maintain GetOldValue()
			{
				return OldValue as Maintain;
			}
		
		#region Seqno属性
			private int m_Seqno = 0;
			/// <summary>
			/// 属性名称： Seqno
			/// 内容摘要： DB列名：seqno[]
			///            DB类型：int
			/// </summary>
			public int Seqno
			{
				get
					{
						return m_Seqno;
					}
				set
					{
						if (m_Seqno as object == null || !m_Seqno.Equals(value))
						{
							m_Seqno = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region 用户姓名属性
			private string m_用户姓名 = String.Empty;
			/// <summary>
			/// 属性名称： 用户姓名
			/// 内容摘要： DB列名：用户姓名[]
			///            DB类型：string
			/// </summary>
			public string 用户姓名
			{
				get
					{
						return m_用户姓名;
					}
				set
					{
						if (m_用户姓名 as object == null || !m_用户姓名.Equals(value))
						{
							m_用户姓名 = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region 联系电话属性
			private string m_联系电话 = String.Empty;
			/// <summary>
			/// 属性名称： 联系电话
			/// 内容摘要： DB列名：联系电话[]
			///            DB类型：string
			/// </summary>
			public string 联系电话
			{
				get
					{
						return m_联系电话;
					}
				set
					{
						if (m_联系电话 as object == null || !m_联系电话.Equals(value))
						{
							m_联系电话 = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region 联系地址属性
			private string m_联系地址 = String.Empty;
			/// <summary>
			/// 属性名称： 联系地址
			/// 内容摘要： DB列名：联系地址[]
			///            DB类型：string
			/// </summary>
			public string 联系地址
			{
				get
					{
						return m_联系地址;
					}
				set
					{
						if (m_联系地址 as object == null || !m_联系地址.Equals(value))
						{
							m_联系地址 = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region 产品型号属性
			private string m_产品型号 = String.Empty;
			/// <summary>
			/// 属性名称： 产品型号
			/// 内容摘要： DB列名：产品型号[]
			///            DB类型：string
			/// </summary>
			public string 产品型号
			{
				get
					{
						return m_产品型号;
					}
				set
					{
						if (m_产品型号 as object == null || !m_产品型号.Equals(value))
						{
							m_产品型号 = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region 订单号属性
			private string m_订单号 = String.Empty;
			/// <summary>
			/// 属性名称： 订单号
			/// 内容摘要： DB列名：订单号[]
			///            DB类型：string
			/// </summary>
			public string 订单号
			{
				get
					{
						return m_订单号;
					}
				set
					{
						if (m_订单号 as object == null || !m_订单号.Equals(value))
						{
							m_订单号 = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Email属性
			private string m_Email = String.Empty;
			/// <summary>
			/// 属性名称： Email
			/// 内容摘要： DB列名：Email[]
			///            DB类型：string
			/// </summary>
			public string Email
			{
				get
					{
						return m_Email;
					}
				set
					{
						if (m_Email as object == null || !m_Email.Equals(value))
						{
							m_Email = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region 故障说明属性
			private string m_故障说明 = String.Empty;
			/// <summary>
			/// 属性名称： 故障说明
			/// 内容摘要： DB列名：故障说明[]
			///            DB类型：string
			/// </summary>
			public string 故障说明
			{
				get
					{
						return m_故障说明;
					}
				set
					{
						if (m_故障说明 as object == null || !m_故障说明.Equals(value))
						{
							m_故障说明 = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Isdo属性
			private int m_Isdo = 0;
			/// <summary>
			/// 属性名称： Isdo
			/// 内容摘要： DB列名：IsDo[]
			///            DB类型：int
			/// </summary>
			public int Isdo
			{
				get
					{
						return m_Isdo;
					}
				set
					{
						if (m_Isdo as object == null || !m_Isdo.Equals(value))
						{
							m_Isdo = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Buydate属性
			private string m_Buydate = String.Empty;
			/// <summary>
			/// 属性名称： Buydate
			/// 内容摘要： DB列名：BuyDate[]
			///            DB类型：string
			/// </summary>
			public string Buydate
			{
				get
					{
						return m_Buydate;
					}
				set
					{
						if (m_Buydate as object == null || !m_Buydate.Equals(value))
						{
							m_Buydate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Createdate属性
			private DateTime m_Createdate = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： Createdate
			/// 内容摘要： DB列名：CreateDate[]
			///            DB类型：DateTime
			/// </summary>
			public DateTime Createdate
			{
				get
					{
						return DateTime.Parse(m_Createdate.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_Createdate as object == null || !m_Createdate.Equals(value))
						{
							m_Createdate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Createby属性
			private string m_Createby = String.Empty;
			/// <summary>
			/// 属性名称： Createby
			/// 内容摘要： DB列名：CreateBy[]
			///            DB类型：string
			/// </summary>
			public string Createby
			{
				get
					{
						return m_Createby;
					}
				set
					{
						if (m_Createby as object == null || !m_Createby.Equals(value))
						{
							m_Createby = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("用户姓名",typeof(string)));
					dtResult.Columns.Add(new DataColumn("联系电话",typeof(string)));
					dtResult.Columns.Add(new DataColumn("联系地址",typeof(string)));
					dtResult.Columns.Add(new DataColumn("产品型号",typeof(string)));
					dtResult.Columns.Add(new DataColumn("订单号",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Email",typeof(string)));
					dtResult.Columns.Add(new DataColumn("故障说明",typeof(string)));
					dtResult.Columns.Add(new DataColumn("IsDo",typeof(int)));
					dtResult.Columns.Add(new DataColumn("BuyDate",typeof(string)));
					dtResult.Columns.Add(new DataColumn("CreateDate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("CreateBy",typeof(string)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("用户姓名",typeof(string)));
					dtResult.Columns.Add(new DataColumn("联系电话",typeof(string)));
					dtResult.Columns.Add(new DataColumn("联系地址",typeof(string)));
					dtResult.Columns.Add(new DataColumn("产品型号",typeof(string)));
					dtResult.Columns.Add(new DataColumn("订单号",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Email",typeof(string)));
					dtResult.Columns.Add(new DataColumn("故障说明",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Isdo",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Buydate",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Createdate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Createby",typeof(string)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["seqno"] = this.Seqno;
					dr["用户姓名"] = this.用户姓名;
					dr["联系电话"] = this.联系电话;
					dr["联系地址"] = this.联系地址;
					dr["产品型号"] = this.产品型号;
					dr["订单号"] = this.订单号;
					dr["Email"] = this.Email;
					dr["故障说明"] = this.故障说明;
					dr["IsDo"] = this.Isdo;
					dr["BuyDate"] = this.Buydate;
					dr["CreateDate"] = this.Createdate;
					dr["CreateBy"] = this.Createby;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["用户姓名"] = this.用户姓名;
					dr["联系电话"] = this.联系电话;
					dr["联系地址"] = this.联系地址;
					dr["产品型号"] = this.产品型号;
					dr["订单号"] = this.订单号;
					dr["Email"] = this.Email;
					dr["故障说明"] = this.故障说明;
					dr["Isdo"] = this.Isdo;
					dr["Buydate"] = this.Buydate;
					dr["Createdate"] = this.Createdate;
					dr["Createby"] = this.Createby;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成Maintain对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>Maintain对象</returns>
			public static Maintain Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				Maintain obj = new Maintain();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.Seqno = (dr["seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["seqno"],typeof(int));
					obj.用户姓名 = (dr["用户姓名"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["用户姓名"],typeof(string));
					obj.联系电话 = (dr["联系电话"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["联系电话"],typeof(string));
					obj.联系地址 = (dr["联系地址"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["联系地址"],typeof(string));
					obj.产品型号 = (dr["产品型号"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["产品型号"],typeof(string));
					obj.订单号 = (dr["订单号"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["订单号"],typeof(string));
					obj.Email = (dr["Email"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Email"],typeof(string));
					obj.故障说明 = (dr["故障说明"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["故障说明"],typeof(string));
					obj.Isdo = (dr["IsDo"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["IsDo"],typeof(int));
					obj.Buydate = (dr["BuyDate"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["BuyDate"],typeof(string));
					obj.Createdate = (dr["CreateDate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["CreateDate"],typeof(DateTime));
					obj.Createby = (dr["CreateBy"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["CreateBy"],typeof(string));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.用户姓名 = (dr["用户姓名"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["用户姓名"],typeof(string));
					obj.联系电话 = (dr["联系电话"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["联系电话"],typeof(string));
					obj.联系地址 = (dr["联系地址"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["联系地址"],typeof(string));
					obj.产品型号 = (dr["产品型号"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["产品型号"],typeof(string));
					obj.订单号 = (dr["订单号"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["订单号"],typeof(string));
					obj.Email = (dr["Email"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Email"],typeof(string));
					obj.故障说明 = (dr["故障说明"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["故障说明"],typeof(string));
					obj.Isdo = (dr["Isdo"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Isdo"],typeof(int));
					obj.Buydate = (dr["Buydate"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Buydate"],typeof(string));
					obj.Createdate = (dr["Createdate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Createdate"],typeof(DateTime));
					obj.Createby = (dr["Createby"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Createby"],typeof(string));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成Maintain对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>Maintain对象</returns>
			public static Maintain Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的Maintain对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>Maintain对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的Maintain对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>Maintain对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的Maintain对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Maintain对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(Maintain obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的Maintain对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Maintain对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			Maintain old = this.OldValue as Maintain;
			if (old != null)
			{
					this.Seqno = old.Seqno;
					this.用户姓名 = old.用户姓名;
					this.联系电话 = old.联系电话;
					this.联系地址 = old.联系地址;
					this.产品型号 = old.产品型号;
					this.订单号 = old.订单号;
					this.Email = old.Email;
					this.故障说明 = old.故障说明;
					this.Isdo = old.Isdo;
					this.Buydate = old.Buydate;
					this.Createdate = old.Createdate;
					this.Createby = old.Createby;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region Maintain实体的内部Key类
			/// <summary>
			/// Maintain实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_Seqno;
				public int Seqno
				{
 					get 
					{ 
						 return m_Seqno; 
					}
					set 
					{ 
						m_Seqno = value;
					}
				}
		
				public Key(int pSeqno)
				{
					m_Seqno=pSeqno;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体Maintain的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(Seqno);				
			}
			
				
		#endregion
	}
}
